package com.bang.study.factory;



/**
 * @ClassName: App
 * @author: BANG
 * @Date: 2019/10/28 14:24
 * @Version: 1.0
 * @Modified By:
 * @Desc: 入口
 */
public class App {

    private final Blacksmith blacksmith;

    public App(Blacksmith blacksmith) {
        this.blacksmith = blacksmith;
    }

    public static void main(String[] args) {
        App app = new App(new HumanBlacksmith());
        app.createWeapons();
        System.out.println("--------------");
        app = new App(new ElfBlacksmith());
        app.createWeapons();
    }

    private void createWeapons() {
        Weapon weapon;
        weapon = blacksmith.createWeapon(WeaponType.SHORT_SWORD);
        System.out.println(weapon.toString());
        weapon = blacksmith.createWeapon(WeaponType.SPEAR);
        System.out.println(weapon.toString());
    }
}
